// gcc -o opengl main.c -lGL -lglut
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <string.h>

int main(int argc, char *argv[])
{
	GLuint idWindow = 0;
	printf( "%s\n", "Hello OpenGL." );
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	idWindow = glutCreateWindow("red 3D lighted cube");
	int glutVersion	= glutGet(0x10FC);
	char* version	= (char*)glGetString(GL_VERSION);
	char* vendor	= (char*)glGetString(GL_VENDOR);
	char* renderer	= (char*)glGetString(GL_RENDERER);
	char* extensions= (char*)glGetString(GL_EXTENSIONS);
	if( version )
	{
		/*
		 * printf("OpenGL Version : %s\n", version);
		 */
		int l = strlen( extensions );
		char *format_ext = (char*)malloc( l+1 );
		strcpy( format_ext, extensions );
		int i = 0;
		for( i=0; i<l; ++i )
		{
			if( format_ext[i] == ' ' )
				format_ext[i] = '\n';
		}
		printf( "GLUT=%d\n"
				"Version=%s\n"
				"Vendor=%s\n"
				"Renderer=%s\n"
				"Extensions=%s\n"
				, glutVersion, version, vendor, renderer, format_ext );
		free(format_ext);
	}
	glutDestroyWindow(idWindow);
	return 0;
}

